home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gnome-core.idb / usr / freeware / include / applet-widget.h.z / applet-widget.h
Encoding:
C/C++ Source or Header  |  1999-07-16  |  7.2 KB  |  209 lines

  1. /* applet-widget: the interface for the applets, these are the functions
  2.  * that applets need
  3.  * (C) 1998 the Free Software Foundation
  4.  *
  5.  * Author:  George Lebl
  6.  */
  7. #ifndef __APPLET_WIDGET_H__
  8. #define __APPLET_WIDGET_H__
  9.  
  10. #include <gtk/gtk.h>
  11. #include <gnome.h>
  12. #include <libgnorba/gnorba.h>
  13.  
  14. #include <gnome-panel.h>
  15.  
  16. #define HAVE_SAVE_SESSION_SIGNAL 1
  17.  
  18. BEGIN_GNOME_DECLS
  19.  
  20. typedef GNOME_Panel_OrientType PanelOrientType;
  21. #define ORIENT_UP GNOME_Panel_ORIENT_UP
  22. #define ORIENT_DOWN GNOME_Panel_ORIENT_DOWN
  23. #define ORIENT_LEFT GNOME_Panel_ORIENT_LEFT
  24. #define ORIENT_RIGHT GNOME_Panel_ORIENT_RIGHT
  25.  
  26. typedef GNOME_Panel_BackType PanelBackType;
  27. #define PANEL_BACK_NONE GNOME_Panel_BACK_NONE
  28. #define PANEL_BACK_COLOR GNOME_Panel_BACK_COLOR
  29. #define PANEL_BACK_PIXMAP GNOME_Panel_BACK_PIXMAP
  30.  
  31.  
  32. #define APPLET_WIDGET(obj)          GTK_CHECK_CAST (obj, applet_widget_get_type (), AppletWidget)
  33. #define APPLET_WIDGET_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, applet_widget_get_type (), AppletWidgetClass)
  34. #define IS_APPLET_WIDGET(obj)       GTK_CHECK_TYPE (obj, applet_widget_get_type ())
  35.  
  36. typedef struct _AppletWidget        AppletWidget;
  37. typedef struct _AppletWidgetClass    AppletWidgetClass;
  38.  
  39. typedef void (*AppletCallbackFunc)(AppletWidget *applet, gpointer data);
  40.  
  41. struct _AppletWidget
  42. {
  43.     GtkPlug            window;
  44.     
  45.     char            *privcfgpath;
  46.     char            *globcfgpath;
  47.  
  48.         gpointer                corbadat; /* CORBA stuff */
  49. };
  50.  
  51. struct _AppletWidgetClass
  52. {
  53.     GtkPlugClass parent_class;
  54.  
  55.     /* when the orientation of the parent panel changes, you should 
  56.        connect this signal before doing applet_widget_add so that
  57.        you get an initial change_orient signal during the add, so
  58.        that you can update your orientation properly */
  59.     void (* change_orient) (AppletWidget *applet,
  60.                 GNOME_Panel_OrientType orient);
  61.     /* the panel background changes, the pixmap handeling is likely
  62.        to change */
  63.     void (* back_change) (AppletWidget *applet,
  64.                   GNOME_Panel_BackType type,
  65.                   char *pixmap,
  66.                   GdkColor *color);
  67.     /*will send the current state of the tooltips, if they are enabled
  68.       or disabled, you should only need this if you are doing something
  69.       weird*/
  70.     void (* tooltip_state) (AppletWidget *applet,
  71.                 int enabled);
  72.     /*when the panel wants to save a session it will call this signal 
  73.       if you trap it make sure you do gnome_config_sync() and
  74.       gnome_config_drop_all() after your done otherwise the changes
  75.       might not be written to file, also make sure you return
  76.       FALSE from this signal or your position wil not get saved!*/
  77.     int (* save_session) (AppletWidget *applet,
  78.                   char *cfgpath,
  79.                   char *globcfgpath);
  80. };
  81.  
  82. typedef GtkWidget *(*AppletFactoryActivator)(const char *goad_id, const char **params, int nparams);
  83. /* Returns TRUE if the factory can activate this applet */
  84. typedef gboolean (*AppletFactoryQuerier)(const char *goad_id);
  85.  
  86. guint        applet_widget_get_type        (void);
  87.  
  88. void            applet_factory_new(const char *goad_id,
  89.                    AppletFactoryQuerier qfunc,
  90.                    AppletFactoryActivator afunc);
  91. GtkWidget*    applet_widget_new(const char *goad_id);
  92.  
  93. /*set tooltip over the applet, NULL to remove a tooltip*/
  94. void        applet_widget_set_tooltip    (AppletWidget *applet,
  95.                          char *text);
  96.  
  97. /*set tooltip on a specific widget inside the applet*/
  98. void        applet_widget_set_widget_tooltip(AppletWidget *applet,
  99.                          GtkWidget *widget,
  100.                          char *text);
  101.  
  102. /* add a widget to the plug and register the applet, this has to
  103.    be done after all the children had been added so that the applet-lib
  104.    can bind the events over them so that peoplce can move them with
  105.    the second button, get the menu, etc ...*/
  106. void        applet_widget_add        (AppletWidget *applet,
  107.                          GtkWidget *widget);
  108.  
  109. /* remove the plug from the panel, this will destroy the applet */
  110. void        applet_widget_remove        (AppletWidget *applet);
  111.  
  112. /* The callback functions control the applet's right click menu, the name
  113.    is just a string, which has to be unique and which controls the nesting,
  114.    for example a name of "foo/bar" will add an item to the submenu
  115.    identified by "/foo" (which you should have created before with
  116.    register_callback_dir, use this for properies callback, help, about,
  117.    etc... etc...
  118. */
  119. /*add a callback onto the applet's right click menu*/
  120. void        applet_widget_register_callback    (AppletWidget *applet,
  121.                          char *name,
  122.                          char *menutext,
  123.                          AppletCallbackFunc func,
  124.                          gpointer data);
  125. void        applet_widget_register_stock_callback    (AppletWidget *applet,
  126.                              char *name,
  127.                              char *stock_type,
  128.                              char *menutext,
  129.                              AppletCallbackFunc func,
  130.                              gpointer data);
  131.  
  132. /*remove a menuitem*/
  133. void        applet_widget_unregister_callback (AppletWidget *applet,
  134.                            char *name);
  135.  
  136. /*add a submenu*/
  137. void        applet_widget_register_callback_dir (AppletWidget *applet,
  138.                              char *name,
  139.                              char *menutext);
  140. void        applet_widget_register_stock_callback_dir (AppletWidget *applet,
  141.                                char *name,
  142.                                char *stock_type,
  143.                                char *menutext);
  144. /*remove a submenu*/
  145. void        applet_widget_unregister_callback_dir (AppletWidget *applet,
  146.                                char *name);
  147.  
  148. /*get thenumber of applets*/
  149. int        applet_widget_get_applet_count    (void);
  150.  
  151. /*tell the panel to save our session here (just saves no shutdown),
  152.   this should be done when you change some of your config and want
  153.   the panel to save it's config, you should NOT call this in the
  154.   session_save handler as it will result in a locked panel*/
  155. void        applet_widget_sync_config    (AppletWidget *applet);
  156.  
  157. /* Get the oprientation the applet should use */
  158. GNOME_Panel_OrientType    applet_widget_get_panel_orient    (AppletWidget *applet);
  159.  
  160. /*use this instead of gnome init, if you want multi applet, you also
  161.   have to specify a "start new applet" function which will launch a new
  162.   applet*/
  163. int        applet_widget_init        (const char *app_id,
  164.                          const char *app_version,
  165.                          int argc,
  166.                          char **argv,
  167.                          struct poptOption *options,
  168.                          unsigned int flags,
  169.                          poptContext *return_ctx);
  170.  
  171. /*abort the applet loading, once applet has been created, this is a way to
  172.   tell the panel to forget about us if we decide we want to quit before
  173.   we add the actual applet to the applet-widget*/
  174. void        applet_widget_abort_load    (AppletWidget *applet);
  175.  
  176. /* use this as gtk_main in applets */
  177. void        applet_widget_gtk_main        (void);
  178.  
  179. /*quit the applet*/
  180. void        applet_widget_gtk_main_quit    (void);
  181.  
  182. /*quit the panel (this will log out the gnome session)*/
  183. void        applet_widget_panel_quit    (void);
  184.  
  185. /* Used by shlib applets */
  186. CORBA_Object applet_widget_corba_activate(GtkWidget *applet,
  187.                       PortableServer_POA poa,
  188.                       const char *goad_id,
  189.                       const char **params,
  190.                       gpointer *impl_ptr,
  191.                       CORBA_Environment *ev);
  192.  
  193. void applet_widget_corba_deactivate(PortableServer_POA poa,
  194.                     const char *goad_id,
  195.                     gpointer impl_ptr,
  196.                     CORBA_Environment *ev);
  197.  
  198.  
  199. #define APPLET_ACTIVATE(func, goad_id, apldat) ({ CORBA_Environment ev; CORBA_exception_init(&ev); \
  200. CORBA_Object_release(func(CORBA_ORB_resolve_initial_references(gnome_CORBA_ORB(), \
  201. "RootPOA", &ev), goad_id, NULL, apldat, &ev), &ev); CORBA_exception_free(&ev); })
  202.  
  203. #define APPLET_DEACTIVATE(func, goad_id, apldat) ({ CORBA_Environment ev; CORBA_exception_init(&ev); \
  204. func(CORBA_ORB_resolve_initial_references(gnome_CORBA_ORB(), "RootPOA", &ev), goad_id, apldat, &ev); CORBA_exception_free(&ev); })
  205.  
  206. END_GNOME_DECLS
  207.  
  208. #endif /* __APPLET_WIDGET_H__ */
  209.